var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (i, t) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, i) {
              e.__proto__ = i;
            }) ||
          function (e, i) {
            for (var t in i)
              Object.prototype.hasOwnProperty.call(i, t) && (e[t] = i[t]);
          })(i, t);
      };
      return function (i, t) {
        function r() {
          this.constructor = i;
        }
        if ("function" != typeof t && null !== t)
          throw new TypeError(
            "Class extends value " + String(t) + " is not a constructor or null"
          );
        e(i, t),
          (i.prototype =
            null === t
              ? Object.create(t)
              : ((r.prototype = t.prototype), new r()));
      };
    })(),
  RepairSkillDialog = (function (e) {
    function i() {
      var i = e.call(this) || this;
      return (
        (i.max = 50),
        (i.min = 1),
        (i.step = 1),
        (i.num = 1),
        (i.list_repari_skill.selectEnable = !0),
        (i.list_repari_skill.renderHandler = new Handler(
          i,
          i.onupdateRepairSkillItemFn
        )),
        (i.list_repari_skill.vScrollBarSkin = ""),
        i.list_repari_skill.on(
          Laya.Event.CLICK,
          i,
          i.onListRepairSkillPropertyAction
        ),
        i.btn_repair_plus.on(Laya.Event.CLICK, i, i.onUserXinFaPlusDidClick),
        i.btn_repair_dele.on(Laya.Event.CLICK, i, i.onUserXinFaPlusDidClick),
        i.slider_repair_wearable.on(Laya.Event.CHANGE, i, i.sliderChange),
        i.btn_repair_xiubu.on(Laya.Event.CLICK, i, i.onRepariSureAction),
        WebSocketService.addListener({
          caller: i,
          code: 4534,
          method: i.onLoadRepairData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 4535,
          method: i.onLoadSureSkillData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 4537,
          method: i.onLoadSureSkillData,
        }),
        i
      );
    }
    return (
      __extends(i, e),
      (i.prototype.onUserXinFaPlusDidClick = function (e) {
        "item1" == e.target.name
          ? ((this.num = this.num + this.step),
            this.num > this.max && (this.num = this.max),
            (this.slider_repair_wearable.value = this.num))
          : ((this.num = this.num - this.step),
            this.num < this.min && (this.num = this.min),
            (this.slider_repair_wearable.value = this.num)),
          (this.label_repair_shuliandu.text = this.num + "");
        var i = (this.num / 3e4) * this.jsonDict.s;
        this.label_repair_shuxing.text = i.toFixed(1) + "";
      }),
      (i.prototype.sliderChange = function () {
        (this.num = this.slider_repair_wearable.value),
          (this.label_repair_shuliandu.text = this.num + "");
        var e = (this.num / 3e4) * this.jsonDict.s;
        this.label_repair_shuxing.text = e.toFixed(1) + "";
      }),
      (i.showRepairDialog = function (e) {
        null == this.repairDialog &&
          ((this.repairDialog = new i()), (this.repairDialog.zOrder = 1001)),
          this.repairDialog.popup(),
          (this.repairDialog.repSkillArr = []),
          (this.repairDialog.repairLevel = "select_shuliandu"),
          (this.repairDialog.jsonDict = e),
          WebSocketService.send({ c: 4534 }),
          (this.repairDialog.num = 0),
          this.repairDialog.showRepairLevel("select_shuliandu");
      }),
      (i.prototype.showRepairLevel = function (e) {
        (this.label_repari_name.text = this.jsonDict.name),
          "select_shuliandu" == e
            ? ((this.list_repari_skill.visible = !0),
              (this.lable_repair_item2.visible = !1),
              (this.label_repair_title.text = "选择消耗熟练度的技能："))
            : "select_property" == e &&
              ((this.list_repari_skill.visible = !1),
              (this.lable_repair_item2.visible = !0),
              (this.label_repair_title.text =
                "消耗" +
                this.jsonDict.name +
                "的熟练度，修补" +
                this.jsonDict.k),
              (this.slider_repair_wearable.value = 0));
      }),
      (i.prototype.onupdateRepairSkillItemFn = function (e, i) {
        if (!(i > this.repSkillArr.length))
          e.getChildByName("label_repair_skill_name"),
            e.getChildByName("btn_repair_skill");
      }),
      (i.prototype.onLoadRepairData = function (e) {
        if (0 == e.code) {
          var i;
          (this.dataSource = []), (this.repSkillArr = e.data);
          for (var t = 0; t < this.repSkillArr.length; t++) {
            var r = this.repSkillArr[t];
            (i = {
              label_repair_skill_name: {
                text: r.n + "  " + r.k + "(" + r.p + ")",
              },
            }),
              this.dataSource.push(i);
          }
          this.list_repari_skill.dataSource = this.dataSource;
        }
      }),
      (i.prototype.onListRepairSkillPropertyAction = function (e) {
        if ("" != e.target.name) {
          this.showRepairLevel("select_property");
          var i = this.repSkillArr[this.list_repari_skill.selectedIndex];
          (this.max = i.p),
            (this.min = 0),
            (this.slider_repair_wearable.max = this.max),
            (this.label_repair_shuliandu.text = "0"),
            (this.label_repair_shuxing.text = "0");
        }
      }),
      (i.prototype.onRepariSureAction = function () {
        var e = this.repSkillArr[this.list_repari_skill.selectedIndex],
          i = e.s,
          t = e.id,
          r = this.jsonDict.sid,
          a = this.num,
          l = this.jsonDict.roleType,
          s = this.jsonDict.cid;
        "zhujiang" == this.jsonDict.type
          ? WebSocketService.send({
              c: 4535,
              d: { fromskill: i, cid: t, toskill: r, num: a, roleType: l },
            })
          : WebSocketService.send({
              c: 4537,
              d: {
                fromSkill: i,
                fromCid: t,
                toSkill: r,
                toCid: s,
                num: a,
                roleType: l,
              },
            });
      }),
      (i.prototype.onLoadSureSkillData = function (e) {
        ToastView.toastView(e.msg),
          this.close(),
          "zhujiang" == this.jsonDict.type
            ? WebSocketService.send({ c: 4542, d: { cid: 0 } })
            : (WebSocketService.send({
                c: 4542,
                d: { cid: this.jsonDict.cid },
              }),
              WebSocketService.send({ c: 1009, d: { id: this.jsonDict.cid } }));
      }),
      i
    );
  })(ui.SuboardinateController.RepairSkillDialogUI);
